****
****
****	Replication file for "The Political Responses of Virtual Assistants"
****
****	Christopher Ojeda
****
****

/*
Note: the values for Siri responses in the categories of "Institutions and Proccesses"
as well as "History and Geography" are zero, but are present as 1% so that a tiny bar
appears on the graph and it does not appear that the graph forgot to include these bars.
*/


**
** Entering data from Excel File
clear
set obs 30
gen org_percent=.
replace org_percent= 16.67 if _n==1
replace org_percent= 80.00 if _n==2
replace org_percent= 22.22 if _n==3
replace org_percent= 57.14 if _n==4
replace org_percent= 66.67 if _n==5

replace org_percent= 66.67 if _n==6
replace org_percent= 90.00 if _n==7
replace org_percent= 88.89 if _n==8
replace org_percent= 85.71 if _n==9
replace org_percent= 77.78 if _n==10

replace org_percent= 1.00 if _n==11
replace org_percent= 30.00 if _n==12
replace org_percent= 22.22 if _n==13
replace org_percent= 28.57 if _n==14
replace org_percent= 1.00 if _n==15

replace org_percent= 61.11 if _n==16
replace org_percent= 90.00 if _n==17
replace org_percent= 55.56 if _n==18
replace org_percent= 85.71 if _n==19
replace org_percent= 66.67 if _n==20

replace org_percent= 22.22 if _n==21
replace org_percent= 70.00 if _n==22
replace org_percent= 33.33 if _n==23
replace org_percent= 42.86 if _n==24
replace org_percent= 44.44 if _n==25

replace org_percent= 27.78 if _n==26
replace org_percent= 60.00 if _n==27
replace org_percent= 33.33 if _n==28
replace org_percent= 71.43 if _n==29
replace org_percent= 55.56 if _n==30


**
** Structuring the data for bar graph
forvalues i=1(1)30{
gen org_percent`i' = .
replace org_percent`i' = org_percent if _n == `i'
}
*

gen n_var = .
replace n_var=1 if _n==1
replace n_var=2 if _n==2
replace n_var=3 if _n==3
replace n_var=4 if _n==4
replace n_var=5 if _n==5

replace n_var=7 if _n==6
replace n_var=8 if _n==7
replace n_var=9 if _n==8
replace n_var=10 if _n==9
replace n_var=11 if _n==10

replace n_var=13 if _n==11
replace n_var=14 if _n==12
replace n_var=15 if _n==13
replace n_var=16 if _n==14
replace n_var=17 if _n==15

replace n_var=19 if _n==16
replace n_var=20 if _n==17
replace n_var=21 if _n==18
replace n_var=22 if _n==19
replace n_var=23 if _n==20

replace n_var=25 if _n==21
replace n_var=26 if _n==22
replace n_var=27 if _n==23
replace n_var=28 if _n==24
replace n_var=29 if _n==25

replace n_var=31 if _n==26
replace n_var=32 if _n==27
replace n_var=33 if _n==28
replace n_var=34 if _n==29
replace n_var=35 if _n==30


**
** Bar graph in color
graph twoway (bar org_percent1 n_var, fcolor("27 158 119") lcolor(gs16) lwidth(medium)) ///
	(bar org_percent2 n_var, fcolor("117 112 179") lcolor(white) lwidth(medium)) ///
	(bar org_percent3 n_var, fcolor("217 95 2") lcolor(white) lwidth(medium)) ///
	(bar org_percent4 n_var, fcolor("231 41 138") lcolor(white) lwidth(medium)) ///
	(bar org_percent5 n_var, fcolor("102 166 30") lcolor(white) lwidth(medium)) /// 
	(bar org_percent6 n_var, fcolor("27 158 119") lcolor(white) lwidth(medium)) ///
	(bar org_percent7 n_var, fcolor("117 112 179") lcolor(white) lwidth(medium)) ///
	(bar org_percent8 n_var, fcolor("217 95 2") lcolor(white) lwidth(medium)) ///
	(bar org_percent9 n_var, fcolor("231 41 138") lcolor(white) lwidth(medium)) ///
	(bar org_percent10 n_var, fcolor("102 166 30") lcolor(white) lwidth(medium)) /// 
	(bar org_percent11 n_var, fcolor("27 158 119") lcolor(white) lwidth(medium)) ///
	(bar org_percent12 n_var, fcolor("117 112 179") lcolor(white) lwidth(medium)) ///
	(bar org_percent13 n_var, fcolor("217 95 2") lcolor(white) lwidth(medium)) ///
	(bar org_percent14 n_var, fcolor("231 41 138") lcolor(white) lwidth(medium)) ///
	(bar org_percent15 n_var, fcolor("102 166 30") lcolor(white) lwidth(medium)) /// 
	(bar org_percent16 n_var, fcolor("27 158 119") lcolor(white) lwidth(medium)) ///
	(bar org_percent17 n_var, fcolor("117 112 179") lcolor(white) lwidth(medium)) ///
	(bar org_percent18 n_var, fcolor("217 95 2") lcolor(white) lwidth(medium)) ///
	(bar org_percent19 n_var, fcolor("231 41 138") lcolor(white) lwidth(medium)) ///
	(bar org_percent20 n_var, fcolor("102 166 30") lcolor(white) lwidth(medium)) /// 	
	(bar org_percent21 n_var, fcolor("27 158 119") lcolor(white) lwidth(medium)) ///
	(bar org_percent22 n_var, fcolor("117 112 179") lcolor(white) lwidth(medium)) ///
	(bar org_percent23 n_var, fcolor("217 95 2") lcolor(white) lwidth(medium)) ///	
	(bar org_percent24 n_var, fcolor("231 41 138") lcolor(white) lwidth(medium)) ///
	(bar org_percent25 n_var, fcolor("102 166 30") lcolor(white) lwidth(medium)) /// 
	(bar org_percent26 n_var, fcolor("27 158 119") lcolor(white) lwidth(medium)) ///
	(bar org_percent27 n_var, fcolor("117 112 179") lcolor(white) lwidth(medium)) ///
	(bar org_percent28 n_var, fcolor("217 95 2") lcolor(white) lwidth(medium)) ///
	(bar org_percent29 n_var, fcolor("231 41 138") lcolor(white) lwidth(medium)) ///
	(bar org_percent30 n_var, fcolor("102 166 30") lcolor(white) lwidth(medium)), /// 
	legend(order(1 2 3 4 5) label(1 "Institutions" "and Processes") label(2 "Figures" "and Parties") label(3 "Foreign" "Affairs") label(4 "Domestic" "Affairs") label(5 "History and" "Geography") rows(1) symxsize(5) size(small) bmargin(zero)) /// 
	ytitle("Correct Responses (%)", size(4)) ///
	ylabel(0 10 20 30 40 50 60 70 80 90 100, labsize(2.5) angle(horizontal) nogrid) ///
	xtitle(" ") xlabel(3 `""Amazon" "Alexa""' 9 `""Google" "Assistant""' 15 `""Apple" "Siri""' 21 `""Microsoft" "Cortana""' 27 "Hound" 33 "Mycroft") ///
	yscale(titlegap(2)) ///
	graphregion(fcolor(white))

	
**
** Bar graph in black and white	
graph twoway (bar org_percent1 n_var, fcolor("247 247 247") lcolor(black) lwidth(thin)) ///
	(bar org_percent2 n_var, fcolor("204 204 204") lcolor(black) lwidth(thin)) ///
	(bar org_percent3 n_var, fcolor("150 150 150") lcolor(black) lwidth(thin)) ///
	(bar org_percent4 n_var, fcolor("99 99 99") lcolor(black) lwidth(thin)) ///
	(bar org_percent5 n_var, fcolor("37 37 37") lcolor(black) lwidth(thin)) /// 
	(bar org_percent6 n_var, fcolor("247 247 247") lcolor(black) lwidth(thin)) ///
	(bar org_percent7 n_var, fcolor("204 204 204") lcolor(black) lwidth(thin)) ///
	(bar org_percent8 n_var, fcolor("150 150 150") lcolor(black) lwidth(thin)) ///
	(bar org_percent9 n_var, fcolor("99 99 99") lcolor(black) lwidth(thin)) ///
	(bar org_percent10 n_var, fcolor("37 37 37") lcolor(black) lwidth(thin)) /// 
	(bar org_percent11 n_var, fcolor("247 247 247") lcolor(black) lwidth(thin)) ///
	(bar org_percent12 n_var, fcolor("204 204 204") lcolor(black) lwidth(thin)) ///
	(bar org_percent13 n_var, fcolor("150 150 150") lcolor(black) lwidth(thin)) ///
	(bar org_percent14 n_var, fcolor("99 99 99") lcolor(black) lwidth(thin)) ///
	(bar org_percent15 n_var, fcolor("37 37 37") lcolor(black) lwidth(thin)) /// 
	(bar org_percent16 n_var, fcolor("247 247 247") lcolor(black) lwidth(thin)) ///
	(bar org_percent17 n_var, fcolor("204 204 204") lcolor(black) lwidth(thin)) ///
	(bar org_percent18 n_var, fcolor("150 150 150") lcolor(black) lwidth(thin)) ///
	(bar org_percent19 n_var, fcolor("99 99 99") lcolor(black) lwidth(thin)) ///
	(bar org_percent20 n_var, fcolor("37 37 37") lcolor(black) lwidth(thin)) /// 	
	(bar org_percent21 n_var, fcolor("247 247 247") lcolor(black) lwidth(thin)) ///
	(bar org_percent22 n_var, fcolor("204 204 204") lcolor(black) lwidth(thin)) ///
	(bar org_percent23 n_var, fcolor("150 150 150") lcolor(black) lwidth(thin)) ///	
	(bar org_percent24 n_var, fcolor("99 99 99") lcolor(black) lwidth(thin)) ///
	(bar org_percent25 n_var, fcolor("37 37 37") lcolor(black) lwidth(thin)) /// 
	(bar org_percent26 n_var, fcolor("247 247 247") lcolor(black) lwidth(thin)) ///
	(bar org_percent27 n_var, fcolor("204 204 204") lcolor(black) lwidth(thin)) ///
	(bar org_percent28 n_var, fcolor("150 150 150") lcolor(black) lwidth(thin)) ///
	(bar org_percent29 n_var, fcolor("99 99 99") lcolor(black) lwidth(thin)) ///
	(bar org_percent30 n_var, fcolor("37 37 37") lcolor(black) lwidth(thin)), /// 
	legend(order(1 2 3 4 5) label(1 "Institutions" "and Processes") label(2 "Figures" "and Parties") label(3 "Foreign" "Affairs") label(4 "Domestic" "Affairs") label(5 "History and" "Geography") rows(1) symxsize(5) size(small) bmargin(zero)) /// 
	ytitle("Correct Responses (%)", size(4)) ///
	ylabel(0 10 20 30 40 50 60 70 80 90 100, labsize(2.5) angle(horizontal) nogrid) ///
	xtitle(" ") xlabel(3 `""Amazon" "Alexa""' 9 `""Google" "Assistant""' 15 `""Apple" "Siri""' 21 `""Microsoft" "Cortana""' 27 "Hound" 33 "Mycroft") ///
	yscale(titlegap(2)) ///
	graphregion(fcolor(white))
	
